package com.ruoyi.exam.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.QuestionBankMapper;
import com.ruoyi.exam.domain.QuestionBank;
import com.ruoyi.exam.service.IQuestionBankService;

/**
 * 题库Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-01
 */
@Service
public class QuestionBankServiceImpl implements IQuestionBankService
{
    @Autowired
    private QuestionBankMapper questionBankMapper;

    /**
     * 查询题库
     * 
     * @param id 题库主键
     * @return 题库
     */
    @Override
    public QuestionBank selectQuestionBankById(Long id)
    {
        return questionBankMapper.selectQuestionBankById(id);
    }

    /**
     * 查询题库列表
     * 
     * @param questionBank 题库
     * @return 题库
     */
    @Override
    public List<QuestionBank> selectQuestionBankList(QuestionBank questionBank)
    {
        return questionBankMapper.selectQuestionBankList(questionBank);
    }

    /**
     * 新增题库
     * 
     * @param questionBank 题库
     * @return 结果
     */
    @Override
    public int insertQuestionBank(QuestionBank questionBank)
    {
        questionBank.setCreateTime(DateUtils.getNowDate());
        return questionBankMapper.insertQuestionBank(questionBank);
    }

    /**
     * 修改题库
     * 
     * @param questionBank 题库
     * @return 结果
     */
    @Override
    public int updateQuestionBank(QuestionBank questionBank)
    {
        questionBank.setUpdateTime(DateUtils.getNowDate());
        return questionBankMapper.updateQuestionBank(questionBank);
    }

    /**
     * 批量删除题库
     * 
     * @param ids 需要删除的题库主键
     * @return 结果
     */
    @Override
    public int deleteQuestionBankByIds(Long[] ids)
    {
        return questionBankMapper.deleteQuestionBankByIds(ids);
    }

    /**
     * 删除题库信息
     * 
     * @param id 题库主键
     * @return 结果
     */
    @Override
    public int deleteQuestionBankById(Long id)
    {
        return questionBankMapper.deleteQuestionBankById(id);
    }

    @Override
    public AjaxResult selectQuestionBankAllList() {
        List<QuestionBank> questionBanks = questionBankMapper.selectQuestionBankAllList();
        return AjaxResult.success(questionBanks);
    }

    @Override
    public AjaxResult allListNotInIds(Long[] ids) {
        List<QuestionBank> questionBanks = questionBankMapper.allListNotInIds(ids);
        return AjaxResult.success(questionBanks);
    }
}
